<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Pink-Ngannv
 * Date: 7/24/11
 * Time: 8:03 PM
 * To change this template use File | Settings | File Templates.
 */
/**
	@comment Cat chuoi khong lam mat y nghia cua noi dung
	@param $string,$start,$length
	@return string
*/
function sub_string($string,$start,$length){
	$length=intval($length);
	$start=intval($start);
	if(strlen($string)<=$start){
		return $string;
	}
	if(strlen($string) > $length){
		$str=substr($string, $start,$length);
		$str=substr($str, $start,strripos($str, ' '));
		return $str;
	}
	return $string;
}
function escape_string($str) {
	if (function_exists ( "mysql_escape_string" )) {
		return mysql_escape_string ( $str );
	}else if(function_exists('mysql_real_escape_string')){
        return mysql_real_escape_string($str);
    } else {
		return  addslashes ( $str );
	}
	return $str;
}

function find_substr($str_root,$str_sub){
    $str_root=strtolower($str_root);
    $str_sub=strtolower($str_sub);
    return strpos($str_root,$str_sub);
}
